ts-markdown-builder 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -2
- package/dist/commonjs/block.js +4 -2
- package/dist/commonjs/block.js.map +1 -1
- package/dist/commonjs/index.js +6 -0
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/inline.js +6 -1
- package/dist/commonjs/inline.js.map +1 -1
- package/dist/commonjs/utils.js +18 -0
- package/dist/commonjs/utils.js.map +1 -1
- package/dist/esm/block.mjs +5 -3
- package/dist/esm/block.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/inline.mjs +6 -1
- package/dist/esm/inline.mjs.map +1 -1
- package/dist/esm/utils.mjs +16 -0
- package/dist/esm/utils.mjs.map +1 -1
- package/dist/types/block.d.ts +6 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils.d.ts +2 -0
- package/package.json +21 -20
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ npm install ts-markdown-builder
|
|
|
27
27
|
```js
|
|
28
28
|
import * as md from 'ts-markdown-builder';
|
|
29
29
|
|
|
30
|
-
const output = [
|
|
30
|
+
const output = md.joinBlocks([
|
|
31
31
|
md.heading('Welcome to TS Markdown Builder'),
|
|
32
32
|
"It's an easy to use modern markdown generator.",
|
|
33
33
|
'It supports:',
|
|
@@ -38,7 +38,7 @@ const output = [
|
|
|
38
38
|
'blockquotes',
|
|
39
39
|
'and more!',
|
|
40
40
|
]),
|
|
41
|
-
]
|
|
41
|
+
]);
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
```markdown
|
|
@@ -55,6 +55,38 @@ It supports:
|
|
|
55
55
|
- and more!
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
## Functions
|
|
59
|
+
|
|
60
|
+
### Utils
|
|
61
|
+
|
|
62
|
+
- `joinBlocks(blocks: string[])` - join blocks of text into a single markdown document (string)
|
|
63
|
+
|
|
64
|
+
### Block
|
|
65
|
+
- `heading(text: string, options?: { level: number = 1 })`
|
|
66
|
+
- `blockquote(text: string | string[])`
|
|
67
|
+
- `codeBlock(text: string, options?: { language?: string = '' })`
|
|
68
|
+
- `list(items: string[])`
|
|
69
|
+
- `orderedList(items: string[])`
|
|
70
|
+
- `horizontalRule`
|
|
71
|
+
|
|
72
|
+
### Inline
|
|
73
|
+
|
|
74
|
+
- `bold(text: string)`
|
|
75
|
+
- `italic(text: string)`
|
|
76
|
+
- `code(text: string)`
|
|
77
|
+
- `link(url: string, text?: string)` - link or autolink
|
|
78
|
+
- `image(url: string, text?: string)`
|
|
79
|
+
- `escape(text: string)`
|
|
80
|
+
|
|
81
|
+
### Table
|
|
82
|
+
|
|
83
|
+
- `table(headers: string[], rows: string[][])`
|
|
84
|
+
|
|
85
|
+
### HTML
|
|
86
|
+
|
|
87
|
+
- `disclosure(title: string, content: string, options?: { open?: boolean })`
|
|
88
|
+
- `lineBreak`
|
|
89
|
+
|
|
58
90
|
## Contributing
|
|
59
91
|
|
|
60
92
|
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
package/dist/commonjs/block.js
CHANGED
|
@@ -15,8 +15,10 @@ function heading(text, options) {
|
|
|
15
15
|
function blockquote(content) {
|
|
16
16
|
return (0, _utils.prefixLines)((0, _utils.joinBlocks)(content), '> ');
|
|
17
17
|
}
|
|
18
|
-
function codeBlock(content) {
|
|
19
|
-
|
|
18
|
+
function codeBlock(content, options) {
|
|
19
|
+
const language = options?.language ?? '';
|
|
20
|
+
const backticks = Math.max((0, _utils.maxBackticks)(content), 2) + 1;
|
|
21
|
+
return '`'.repeat(backticks) + language + '\n' + content + '\n' + '`'.repeat(backticks);
|
|
20
22
|
}
|
|
21
23
|
function list(items) {
|
|
22
24
|
return items.map(item => `- ${item}`).join('\n');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.js","names":["horizontalRule","exports","heading","text","options","level","repeat","blockquote","content","prefixLines","joinBlocks","codeBlock","list","items","map","item","join","orderedList","index"],"sources":["../../src/block.ts"],"sourcesContent":["import { joinBlocks, prefixLines } from './utils';\n\n/**\n * Create a horizontal rule block.\n *\n * Markdown: `---`\n */\nexport const horizontalRule = '---';\n\ntype HeadingOptions = {\n level: number;\n};\n\n/**\n * Create a heading block.\n * Markdown: `# Heading`\n *\n * @param text - The text of the heading.\n * @param level - The level of the heading (defaults to 1).\n */\nexport function heading(text: string, options?: HeadingOptions): string {\n const level = options?.level ?? 1;\n return `${'#'.repeat(level)} ${text}`;\n}\n\n/**\n * Create a blockquote block.\n *\n * Markdown:\n * ```\n * > Content\n * > Content\n * ```\n *\n * @param text - The content of the blockquote.\n */\nexport function blockquote(content: string | readonly string[]): string {\n return prefixLines(joinBlocks(content), '> ');\n}\n\n/**\n * Create a code block.\n *\n * Markdown:\n *
|
|
1
|
+
{"version":3,"file":"block.js","names":["horizontalRule","exports","heading","text","options","level","repeat","blockquote","content","prefixLines","joinBlocks","codeBlock","language","backticks","Math","max","maxBackticks","list","items","map","item","join","orderedList","index"],"sources":["../../src/block.ts"],"sourcesContent":["import { joinBlocks, maxBackticks, prefixLines } from './utils';\n\n/**\n * Create a horizontal rule block.\n *\n * Markdown: `---`\n */\nexport const horizontalRule = '---';\n\ntype HeadingOptions = {\n level: number;\n};\n\n/**\n * Create a heading block.\n * Markdown: `# Heading`\n *\n * @param text - The text of the heading.\n * @param level - The level of the heading (defaults to 1).\n */\nexport function heading(text: string, options?: HeadingOptions): string {\n const level = options?.level ?? 1;\n return `${'#'.repeat(level)} ${text}`;\n}\n\n/**\n * Create a blockquote block.\n *\n * Markdown:\n * ```\n * > Content\n * > Content\n * ```\n *\n * @param text - The content of the blockquote.\n */\nexport function blockquote(content: string | readonly string[]): string {\n return prefixLines(joinBlocks(content), '> ');\n}\n\ntype CodeBlockOptions = {\n language?: string;\n};\n\n/**\n * Create a code block.\n *\n * Markdown:\n * ```js\n * Content\n * ```\n *\n * @param content - The content of the code block.\n * @param language - The language of the code block.\n */\nexport function codeBlock(content: string, options?: CodeBlockOptions): string {\n const language = options?.language ?? '';\n const backticks = Math.max(maxBackticks(content), 2) + 1;\n return '`'.repeat(backticks) + language + '\\n' + content + '\\n' + '`'.repeat(backticks);\n}\n\n/**\n * Create an unordered list block.\n *\n * Markdown:\n * ```\n * - Item\n * - Item\n * ```\n *\n * @param items - The items of the list.\n */\nexport function list(items: readonly string[]): string {\n return items.map((item) => `- ${item}`).join('\\n');\n}\n\n/**\n * Create an ordered list block.\n *\n * Markdown:\n * ```\n * 1. Item\n * 2. Item\n * ```\n *\n * @param items - The items of the list.\n */\nexport function orderedList(items: readonly string[]): string {\n return items.map((item, index) => `${index + 1}. ${item}`).join('\\n');\n}\n"],"mappings":";;;;;;;;;AAOO,MAAMA,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,KAAK;AAa5B,SAASE,OAAOA,CAACC,IAAY,EAAEC,OAAwB,EAAU;EACtE,MAAMC,KAAK,GAAGD,OAAO,EAAEC,KAAK,IAAI,CAAC;EACjC,OAAO,GAAG,GAAG,CAACC,MAAM,CAACD,KAAK,CAAC,IAAIF,IAAI,EAAE;AACvC;AAaO,SAASI,UAAUA,CAACC,OAAmC,EAAU;EACtE,OAAO,IAAAC,kBAAW,EAAC,IAAAC,iBAAU,EAACF,OAAO,CAAC,EAAE,IAAI,CAAC;AAC/C;AAiBO,SAASG,SAASA,CAACH,OAAe,EAAEJ,OAA0B,EAAU;EAC7E,MAAMQ,QAAQ,GAAGR,OAAO,EAAEQ,QAAQ,IAAI,EAAE;EACxC,MAAMC,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,IAAAC,mBAAY,EAACR,OAAO,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC;EACxD,OAAO,GAAG,CAACF,MAAM,CAACO,SAAS,CAAC,GAAGD,QAAQ,GAAG,IAAI,GAAGJ,OAAO,GAAG,IAAI,GAAG,GAAG,CAACF,MAAM,CAACO,SAAS,CAAC;AACzF;AAaO,SAASI,IAAIA,CAACC,KAAwB,EAAU;EACrD,OAAOA,KAAK,CAACC,GAAG,CAAEC,IAAI,IAAK,KAAKA,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AACpD;AAaO,SAASC,WAAWA,CAACJ,KAAwB,EAAU;EAC5D,OAAOA,KAAK,CAACC,GAAG,CAAC,CAACC,IAAI,EAAEG,KAAK,KAAK,GAAGA,KAAK,GAAG,CAAC,KAAKH,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AACvE","ignoreList":[]}
|
package/dist/commonjs/index.js
CHANGED
|
@@ -30,6 +30,12 @@ Object.defineProperty(exports, "disclosure", {
|
|
|
30
30
|
return _html.disclosure;
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
|
+
Object.defineProperty(exports, "escape", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () {
|
|
36
|
+
return _utils.escape;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
33
39
|
Object.defineProperty(exports, "heading", {
|
|
34
40
|
enumerable: true,
|
|
35
41
|
get: function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } from './block';\nexport { code, italic, bold, link, image } from './inline';\nexport { table } from './table';\nexport { lineBreak, disclosure } from './html';\nexport { joinBlocks } from './utils';\n\nexport type { TableOptions } from './table';\nexport type { DisclosureOptions } from './html';\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } from './block';\nexport { code, italic, bold, link, image } from './inline';\nexport { table } from './table';\nexport { lineBreak, disclosure } from './html';\nexport { escape, joinBlocks } from './utils';\n\nexport type { TableOptions } from './table';\nexport type { DisclosureOptions } from './html';\n"],"mappings":"","ignoreList":[]}
|
package/dist/commonjs/inline.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.code = code;
|
|
|
5
5
|
exports.image = image;
|
|
6
6
|
exports.italic = italic;
|
|
7
7
|
exports.link = link;
|
|
8
|
+
var _utils = require("./utils.js");
|
|
8
9
|
function italic(text) {
|
|
9
10
|
return `*${text}*`;
|
|
10
11
|
}
|
|
@@ -12,7 +13,11 @@ function bold(text) {
|
|
|
12
13
|
return `**${text}**`;
|
|
13
14
|
}
|
|
14
15
|
function code(text) {
|
|
15
|
-
|
|
16
|
+
const backticksCount = (0, _utils.maxBackticks)(text) + 1;
|
|
17
|
+
const backticks = '`'.repeat(backticksCount);
|
|
18
|
+
const frontPadding = text.startsWith('`') ? ' ' : '';
|
|
19
|
+
const backPadding = text.endsWith('`') ? ' ' : '';
|
|
20
|
+
return `${backticks}${frontPadding}${text}${backPadding}${backticks}`;
|
|
16
21
|
}
|
|
17
22
|
function link(url, text) {
|
|
18
23
|
return text ? `[${text}](${url})` : `<${url}>`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline.js","names":["italic","text","bold","code","link","url","image"],"sources":["../../src/inline.ts"],"sourcesContent":["/**\n * Create an italic text.\n *\n * Markdown: `*text*`\n *\n * @param text - The text to be italicized.\n */\nexport function italic(text: string): string {\n return `*${text}*`;\n}\n\n/**\n * Create a bold text.\n *\n * Markdown: `**text**`\n *\n * @param text - The text to be bolded.\n */\nexport function bold(text: string): string {\n return `**${text}**`;\n}\n\n/**\n * Create a code text.\n *\n * Markdown: `code`\n *\n * @param text - The text to be marked as code.\n */\nexport function code(text: string): string {\n return
|
|
1
|
+
{"version":3,"file":"inline.js","names":["italic","text","bold","code","backticksCount","maxBackticks","backticks","repeat","frontPadding","startsWith","backPadding","endsWith","link","url","image"],"sources":["../../src/inline.ts"],"sourcesContent":["import { maxBackticks } from './utils';\n\n/**\n * Create an italic text.\n *\n * Markdown: `*text*`\n *\n * @param text - The text to be italicized.\n */\nexport function italic(text: string): string {\n return `*${text}*`;\n}\n\n/**\n * Create a bold text.\n *\n * Markdown: `**text**`\n *\n * @param text - The text to be bolded.\n */\nexport function bold(text: string): string {\n return `**${text}**`;\n}\n\n/**\n * Create a code text.\n *\n * Markdown: `code`\n *\n * @param text - The text to be marked as code.\n */\nexport function code(text: string): string {\n const backticksCount = maxBackticks(text) + 1;\n const backticks = '`'.repeat(backticksCount);\n const frontPadding = text.startsWith('`') ? ' ' : '';\n const backPadding = text.endsWith('`') ? ' ' : '';\n return `${backticks}${frontPadding}${text}${backPadding}${backticks}`;\n}\n\n/**\n * Create a link or autolink span.\n *\n * Markdown:\n * - `[text](url)` link when `text` is provided\n * - `<url>` autolink when `text` is not provided\n *\n * @param url - The URL to be linked.\n * @param text - The title for the link (optional).\n */\nexport function link(url: string, text?: string): string {\n return text ? `[${text}](${url})` : `<${url}>`;\n}\n\n/**\n * Create an image text.\n *\n * Markdown: ``\n *\n * @param url - The URL of the image.\n * @param text - The description for the image (optional).\n */\nexport function image(url: string, text?: string): string {\n return ``;\n}\n"],"mappings":";;;;;;;;AASO,SAASA,MAAMA,CAACC,IAAY,EAAU;EAC3C,OAAO,IAAIA,IAAI,GAAG;AACpB;AASO,SAASC,IAAIA,CAACD,IAAY,EAAU;EACzC,OAAO,KAAKA,IAAI,IAAI;AACtB;AASO,SAASE,IAAIA,CAACF,IAAY,EAAU;EACzC,MAAMG,cAAc,GAAG,IAAAC,mBAAY,EAACJ,IAAI,CAAC,GAAG,CAAC;EAC7C,MAAMK,SAAS,GAAG,GAAG,CAACC,MAAM,CAACH,cAAc,CAAC;EAC5C,MAAMI,YAAY,GAAGP,IAAI,CAACQ,UAAU,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE;EACpD,MAAMC,WAAW,GAAGT,IAAI,CAACU,QAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE;EACjD,OAAO,GAAGL,SAAS,GAAGE,YAAY,GAAGP,IAAI,GAAGS,WAAW,GAAGJ,SAAS,EAAE;AACvE;AAYO,SAASM,IAAIA,CAACC,GAAW,EAAEZ,IAAa,EAAU;EACvD,OAAOA,IAAI,GAAG,IAAIA,IAAI,KAAKY,GAAG,GAAG,GAAG,IAAIA,GAAG,GAAG;AAChD;AAUO,SAASC,KAAKA,CAACD,GAAW,EAAEZ,IAAa,EAAU;EACxD,OAAO,KAAKA,IAAI,IAAI,EAAE,KAAKY,GAAG,GAAG;AACnC","ignoreList":[]}
|
package/dist/commonjs/utils.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
exports.escape = escape;
|
|
3
4
|
exports.joinBlocks = joinBlocks;
|
|
5
|
+
exports.maxBackticks = maxBackticks;
|
|
4
6
|
exports.prefixLines = prefixLines;
|
|
5
7
|
function joinBlocks(blocks) {
|
|
6
8
|
blocks = typeof blocks === 'string' ? [blocks] : blocks;
|
|
@@ -13,4 +15,20 @@ function prefixLines(text, prefix) {
|
|
|
13
15
|
const lines = text.split('\n');
|
|
14
16
|
return lines.map(line => `${prefix}${line}`).join('\n');
|
|
15
17
|
}
|
|
18
|
+
function escape(text) {
|
|
19
|
+
return text.replace(/([\\`*_{}[\]()#+\-.!|<>])/g, '\\$1');
|
|
20
|
+
}
|
|
21
|
+
function maxBackticks(text) {
|
|
22
|
+
let max = 0;
|
|
23
|
+
let current = 0;
|
|
24
|
+
for (let i = 0; i < text.length; i++) {
|
|
25
|
+
if (text[i] === '`') {
|
|
26
|
+
current++;
|
|
27
|
+
max = Math.max(max, current);
|
|
28
|
+
} else {
|
|
29
|
+
current = 0;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return max;
|
|
33
|
+
}
|
|
16
34
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["joinBlocks","blocks","map","trimBlock","filter","Boolean","join","block","replace","prefixLines","text","prefix","lines","split","line"],"sources":["../../src/utils.ts"],"sourcesContent":["/**\n * Join blocks of text into a single markdown document (string).\n *\n * @param blocks - The blocks of text to join.\n * @returns Markdown document string.\n */\nexport function joinBlocks(blocks: string | readonly string[]): string {\n blocks = typeof blocks === 'string' ? [blocks] : blocks;\n\n return blocks.map(trimBlock).filter(Boolean).join('\\n\\n');\n}\n\nfunction trimBlock(block: string): string {\n return block.replace(/^\\n+|\\n+$/g, '');\n}\n\nexport function prefixLines(text: string, prefix: string): string {\n const lines = text.split('\\n');\n return lines.map((line) => `${prefix}${line}`).join('\\n');\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","names":["joinBlocks","blocks","map","trimBlock","filter","Boolean","join","block","replace","prefixLines","text","prefix","lines","split","line","escape","maxBackticks","max","current","i","length","Math"],"sources":["../../src/utils.ts"],"sourcesContent":["/**\n * Join blocks of text into a single markdown document (string).\n *\n * @param blocks - The blocks of text to join.\n * @returns Markdown document string.\n */\nexport function joinBlocks(blocks: string | readonly string[]): string {\n blocks = typeof blocks === 'string' ? [blocks] : blocks;\n\n return blocks.map(trimBlock).filter(Boolean).join('\\n\\n');\n}\n\nfunction trimBlock(block: string): string {\n return block.replace(/^\\n+|\\n+$/g, '');\n}\n\nexport function prefixLines(text: string, prefix: string): string {\n const lines = text.split('\\n');\n return lines.map((line) => `${prefix}${line}`).join('\\n');\n}\n\nexport function escape(text: string): string {\n return text.replace(/([\\\\`*_{}[\\]()#+\\-.!|<>])/g, '\\\\$1');\n}\n\nexport function maxBackticks(text: string): number {\n let max = 0;\n let current = 0;\n\n for (let i = 0; i < text.length; i++) {\n if (text[i] === '`') {\n current++;\n max = Math.max(max, current);\n } else {\n current = 0;\n }\n }\n\n return max;\n}\n"],"mappings":";;;;;;AAMO,SAASA,UAAUA,CAACC,MAAkC,EAAU;EACrEA,MAAM,GAAG,OAAOA,MAAM,KAAK,QAAQ,GAAG,CAACA,MAAM,CAAC,GAAGA,MAAM;EAEvD,OAAOA,MAAM,CAACC,GAAG,CAACC,SAAS,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,MAAM,CAAC;AAC3D;AAEA,SAASH,SAASA,CAACI,KAAa,EAAU;EACxC,OAAOA,KAAK,CAACC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;AACxC;AAEO,SAASC,WAAWA,CAACC,IAAY,EAAEC,MAAc,EAAU;EAChE,MAAMC,KAAK,GAAGF,IAAI,CAACG,KAAK,CAAC,IAAI,CAAC;EAC9B,OAAOD,KAAK,CAACV,GAAG,CAAEY,IAAI,IAAK,GAAGH,MAAM,GAAGG,IAAI,EAAE,CAAC,CAACR,IAAI,CAAC,IAAI,CAAC;AAC3D;AAEO,SAASS,MAAMA,CAACL,IAAY,EAAU;EAC3C,OAAOA,IAAI,CAACF,OAAO,CAAC,4BAA4B,EAAE,MAAM,CAAC;AAC3D;AAEO,SAASQ,YAAYA,CAACN,IAAY,EAAU;EACjD,IAAIO,GAAG,GAAG,CAAC;EACX,IAAIC,OAAO,GAAG,CAAC;EAEf,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGT,IAAI,CAACU,MAAM,EAAED,CAAC,EAAE,EAAE;IACpC,IAAIT,IAAI,CAACS,CAAC,CAAC,KAAK,GAAG,EAAE;MACnBD,OAAO,EAAE;MACTD,GAAG,GAAGI,IAAI,CAACJ,GAAG,CAACA,GAAG,EAAEC,OAAO,CAAC;IAC9B,CAAC,MAAM;MACLA,OAAO,GAAG,CAAC;IACb;EACF;EAEA,OAAOD,GAAG;AACZ","ignoreList":[]}
|
package/dist/esm/block.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { joinBlocks, prefixLines } from "./utils.mjs";
|
|
1
|
+
import { joinBlocks, maxBackticks, prefixLines } from "./utils.mjs";
|
|
2
2
|
export const horizontalRule = '---';
|
|
3
3
|
export function heading(text, options) {
|
|
4
4
|
const level = options?.level ?? 1;
|
|
@@ -7,8 +7,10 @@ export function heading(text, options) {
|
|
|
7
7
|
export function blockquote(content) {
|
|
8
8
|
return prefixLines(joinBlocks(content), '> ');
|
|
9
9
|
}
|
|
10
|
-
export function codeBlock(content) {
|
|
11
|
-
|
|
10
|
+
export function codeBlock(content, options) {
|
|
11
|
+
const language = options?.language ?? '';
|
|
12
|
+
const backticks = Math.max(maxBackticks(content), 2) + 1;
|
|
13
|
+
return '`'.repeat(backticks) + language + '\n' + content + '\n' + '`'.repeat(backticks);
|
|
12
14
|
}
|
|
13
15
|
export function list(items) {
|
|
14
16
|
return items.map(item => `- ${item}`).join('\n');
|
package/dist/esm/block.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.mjs","names":["joinBlocks","prefixLines","horizontalRule","heading","text","options","level","repeat","blockquote","content","codeBlock","list","items","map","item","join","orderedList","index"],"sources":["../../src/block.ts"],"sourcesContent":["import { joinBlocks, prefixLines } from './utils';\n\n/**\n * Create a horizontal rule block.\n *\n * Markdown: `---`\n */\nexport const horizontalRule = '---';\n\ntype HeadingOptions = {\n level: number;\n};\n\n/**\n * Create a heading block.\n * Markdown: `# Heading`\n *\n * @param text - The text of the heading.\n * @param level - The level of the heading (defaults to 1).\n */\nexport function heading(text: string, options?: HeadingOptions): string {\n const level = options?.level ?? 1;\n return `${'#'.repeat(level)} ${text}`;\n}\n\n/**\n * Create a blockquote block.\n *\n * Markdown:\n * ```\n * > Content\n * > Content\n * ```\n *\n * @param text - The content of the blockquote.\n */\nexport function blockquote(content: string | readonly string[]): string {\n return prefixLines(joinBlocks(content), '> ');\n}\n\n/**\n * Create a code block.\n *\n * Markdown:\n *
|
|
1
|
+
{"version":3,"file":"block.mjs","names":["joinBlocks","maxBackticks","prefixLines","horizontalRule","heading","text","options","level","repeat","blockquote","content","codeBlock","language","backticks","Math","max","list","items","map","item","join","orderedList","index"],"sources":["../../src/block.ts"],"sourcesContent":["import { joinBlocks, maxBackticks, prefixLines } from './utils';\n\n/**\n * Create a horizontal rule block.\n *\n * Markdown: `---`\n */\nexport const horizontalRule = '---';\n\ntype HeadingOptions = {\n level: number;\n};\n\n/**\n * Create a heading block.\n * Markdown: `# Heading`\n *\n * @param text - The text of the heading.\n * @param level - The level of the heading (defaults to 1).\n */\nexport function heading(text: string, options?: HeadingOptions): string {\n const level = options?.level ?? 1;\n return `${'#'.repeat(level)} ${text}`;\n}\n\n/**\n * Create a blockquote block.\n *\n * Markdown:\n * ```\n * > Content\n * > Content\n * ```\n *\n * @param text - The content of the blockquote.\n */\nexport function blockquote(content: string | readonly string[]): string {\n return prefixLines(joinBlocks(content), '> ');\n}\n\ntype CodeBlockOptions = {\n language?: string;\n};\n\n/**\n * Create a code block.\n *\n * Markdown:\n * ```js\n * Content\n * ```\n *\n * @param content - The content of the code block.\n * @param language - The language of the code block.\n */\nexport function codeBlock(content: string, options?: CodeBlockOptions): string {\n const language = options?.language ?? '';\n const backticks = Math.max(maxBackticks(content), 2) + 1;\n return '`'.repeat(backticks) + language + '\\n' + content + '\\n' + '`'.repeat(backticks);\n}\n\n/**\n * Create an unordered list block.\n *\n * Markdown:\n * ```\n * - Item\n * - Item\n * ```\n *\n * @param items - The items of the list.\n */\nexport function list(items: readonly string[]): string {\n return items.map((item) => `- ${item}`).join('\\n');\n}\n\n/**\n * Create an ordered list block.\n *\n * Markdown:\n * ```\n * 1. Item\n * 2. Item\n * ```\n *\n * @param items - The items of the list.\n */\nexport function orderedList(items: readonly string[]): string {\n return items.map((item, index) => `${index + 1}. ${item}`).join('\\n');\n}\n"],"mappings":"SAASA,UAAU,EAAEC,YAAY,EAAEC,WAAW;AAO9C,OAAO,MAAMC,cAAc,GAAG,KAAK;AAanC,OAAO,SAASC,OAAOA,CAACC,IAAY,EAAEC,OAAwB,EAAU;EACtE,MAAMC,KAAK,GAAGD,OAAO,EAAEC,KAAK,IAAI,CAAC;EACjC,OAAO,GAAG,GAAG,CAACC,MAAM,CAACD,KAAK,CAAC,IAAIF,IAAI,EAAE;AACvC;AAaA,OAAO,SAASI,UAAUA,CAACC,OAAmC,EAAU;EACtE,OAAOR,WAAW,CAACF,UAAU,CAACU,OAAO,CAAC,EAAE,IAAI,CAAC;AAC/C;AAiBA,OAAO,SAASC,SAASA,CAACD,OAAe,EAAEJ,OAA0B,EAAU;EAC7E,MAAMM,QAAQ,GAAGN,OAAO,EAAEM,QAAQ,IAAI,EAAE;EACxC,MAAMC,SAAS,GAAGC,IAAI,CAACC,GAAG,CAACd,YAAY,CAACS,OAAO,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC;EACxD,OAAO,GAAG,CAACF,MAAM,CAACK,SAAS,CAAC,GAAGD,QAAQ,GAAG,IAAI,GAAGF,OAAO,GAAG,IAAI,GAAG,GAAG,CAACF,MAAM,CAACK,SAAS,CAAC;AACzF;AAaA,OAAO,SAASG,IAAIA,CAACC,KAAwB,EAAU;EACrD,OAAOA,KAAK,CAACC,GAAG,CAAEC,IAAI,IAAK,KAAKA,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AACpD;AAaA,OAAO,SAASC,WAAWA,CAACJ,KAAwB,EAAU;EAC5D,OAAOA,KAAK,CAACC,GAAG,CAAC,CAACC,IAAI,EAAEG,KAAK,KAAK,GAAGA,KAAK,GAAG,CAAC,KAAKH,IAAI,EAAE,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;AACvE","ignoreList":[]}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -2,5 +2,5 @@ export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } fro
|
|
|
2
2
|
export { code, italic, bold, link, image } from "./inline.mjs";
|
|
3
3
|
export { table } from "./table.mjs";
|
|
4
4
|
export { lineBreak, disclosure } from "./html.mjs";
|
|
5
|
-
export { joinBlocks } from "./utils.mjs";
|
|
5
|
+
export { escape, joinBlocks } from "./utils.mjs";
|
|
6
6
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["horizontalRule","heading","blockquote","orderedList","list","codeBlock","code","italic","bold","link","image","table","lineBreak","disclosure","joinBlocks"],"sources":["../../src/index.ts"],"sourcesContent":["export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } from './block';\nexport { code, italic, bold, link, image } from './inline';\nexport { table } from './table';\nexport { lineBreak, disclosure } from './html';\nexport { joinBlocks } from './utils';\n\nexport type { TableOptions } from './table';\nexport type { DisclosureOptions } from './html';\n"],"mappings":"SAASA,cAAc,EAAEC,OAAO,EAAEC,UAAU,EAAEC,WAAW,EAAEC,IAAI,EAAEC,SAAS;AAAA,SACjEC,IAAI,EAAEC,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAK;AAAA,SAC/BC,KAAK;AAAA,SACLC,SAAS,EAAEC,UAAU;AAAA,SACrBC,UAAU","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["horizontalRule","heading","blockquote","orderedList","list","codeBlock","code","italic","bold","link","image","table","lineBreak","disclosure","escape","joinBlocks"],"sources":["../../src/index.ts"],"sourcesContent":["export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } from './block';\nexport { code, italic, bold, link, image } from './inline';\nexport { table } from './table';\nexport { lineBreak, disclosure } from './html';\nexport { escape, joinBlocks } from './utils';\n\nexport type { TableOptions } from './table';\nexport type { DisclosureOptions } from './html';\n"],"mappings":"SAASA,cAAc,EAAEC,OAAO,EAAEC,UAAU,EAAEC,WAAW,EAAEC,IAAI,EAAEC,SAAS;AAAA,SACjEC,IAAI,EAAEC,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAK;AAAA,SAC/BC,KAAK;AAAA,SACLC,SAAS,EAAEC,UAAU;AAAA,SACrBC,MAAM,EAAEC,UAAU","ignoreList":[]}
|
package/dist/esm/inline.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { maxBackticks } from "./utils.mjs";
|
|
1
2
|
export function italic(text) {
|
|
2
3
|
return `*${text}*`;
|
|
3
4
|
}
|
|
@@ -5,7 +6,11 @@ export function bold(text) {
|
|
|
5
6
|
return `**${text}**`;
|
|
6
7
|
}
|
|
7
8
|
export function code(text) {
|
|
8
|
-
|
|
9
|
+
const backticksCount = maxBackticks(text) + 1;
|
|
10
|
+
const backticks = '`'.repeat(backticksCount);
|
|
11
|
+
const frontPadding = text.startsWith('`') ? ' ' : '';
|
|
12
|
+
const backPadding = text.endsWith('`') ? ' ' : '';
|
|
13
|
+
return `${backticks}${frontPadding}${text}${backPadding}${backticks}`;
|
|
9
14
|
}
|
|
10
15
|
export function link(url, text) {
|
|
11
16
|
return text ? `[${text}](${url})` : `<${url}>`;
|
package/dist/esm/inline.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline.mjs","names":["italic","text","bold","code","link","url","image"],"sources":["../../src/inline.ts"],"sourcesContent":["/**\n * Create an italic text.\n *\n * Markdown: `*text*`\n *\n * @param text - The text to be italicized.\n */\nexport function italic(text: string): string {\n return `*${text}*`;\n}\n\n/**\n * Create a bold text.\n *\n * Markdown: `**text**`\n *\n * @param text - The text to be bolded.\n */\nexport function bold(text: string): string {\n return `**${text}**`;\n}\n\n/**\n * Create a code text.\n *\n * Markdown: `code`\n *\n * @param text - The text to be marked as code.\n */\nexport function code(text: string): string {\n return
|
|
1
|
+
{"version":3,"file":"inline.mjs","names":["maxBackticks","italic","text","bold","code","backticksCount","backticks","repeat","frontPadding","startsWith","backPadding","endsWith","link","url","image"],"sources":["../../src/inline.ts"],"sourcesContent":["import { maxBackticks } from './utils';\n\n/**\n * Create an italic text.\n *\n * Markdown: `*text*`\n *\n * @param text - The text to be italicized.\n */\nexport function italic(text: string): string {\n return `*${text}*`;\n}\n\n/**\n * Create a bold text.\n *\n * Markdown: `**text**`\n *\n * @param text - The text to be bolded.\n */\nexport function bold(text: string): string {\n return `**${text}**`;\n}\n\n/**\n * Create a code text.\n *\n * Markdown: `code`\n *\n * @param text - The text to be marked as code.\n */\nexport function code(text: string): string {\n const backticksCount = maxBackticks(text) + 1;\n const backticks = '`'.repeat(backticksCount);\n const frontPadding = text.startsWith('`') ? ' ' : '';\n const backPadding = text.endsWith('`') ? ' ' : '';\n return `${backticks}${frontPadding}${text}${backPadding}${backticks}`;\n}\n\n/**\n * Create a link or autolink span.\n *\n * Markdown:\n * - `[text](url)` link when `text` is provided\n * - `<url>` autolink when `text` is not provided\n *\n * @param url - The URL to be linked.\n * @param text - The title for the link (optional).\n */\nexport function link(url: string, text?: string): string {\n return text ? `[${text}](${url})` : `<${url}>`;\n}\n\n/**\n * Create an image text.\n *\n * Markdown: ``\n *\n * @param url - The URL of the image.\n * @param text - The description for the image (optional).\n */\nexport function image(url: string, text?: string): string {\n return ``;\n}\n"],"mappings":"SAASA,YAAY;AASrB,OAAO,SAASC,MAAMA,CAACC,IAAY,EAAU;EAC3C,OAAO,IAAIA,IAAI,GAAG;AACpB;AASA,OAAO,SAASC,IAAIA,CAACD,IAAY,EAAU;EACzC,OAAO,KAAKA,IAAI,IAAI;AACtB;AASA,OAAO,SAASE,IAAIA,CAACF,IAAY,EAAU;EACzC,MAAMG,cAAc,GAAGL,YAAY,CAACE,IAAI,CAAC,GAAG,CAAC;EAC7C,MAAMI,SAAS,GAAG,GAAG,CAACC,MAAM,CAACF,cAAc,CAAC;EAC5C,MAAMG,YAAY,GAAGN,IAAI,CAACO,UAAU,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE;EACpD,MAAMC,WAAW,GAAGR,IAAI,CAACS,QAAQ,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE;EACjD,OAAO,GAAGL,SAAS,GAAGE,YAAY,GAAGN,IAAI,GAAGQ,WAAW,GAAGJ,SAAS,EAAE;AACvE;AAYA,OAAO,SAASM,IAAIA,CAACC,GAAW,EAAEX,IAAa,EAAU;EACvD,OAAOA,IAAI,GAAG,IAAIA,IAAI,KAAKW,GAAG,GAAG,GAAG,IAAIA,GAAG,GAAG;AAChD;AAUA,OAAO,SAASC,KAAKA,CAACD,GAAW,EAAEX,IAAa,EAAU;EACxD,OAAO,KAAKA,IAAI,IAAI,EAAE,KAAKW,GAAG,GAAG;AACnC","ignoreList":[]}
|
package/dist/esm/utils.mjs
CHANGED
|
@@ -9,4 +9,20 @@ export function prefixLines(text, prefix) {
|
|
|
9
9
|
const lines = text.split('\n');
|
|
10
10
|
return lines.map(line => `${prefix}${line}`).join('\n');
|
|
11
11
|
}
|
|
12
|
+
export function escape(text) {
|
|
13
|
+
return text.replace(/([\\`*_{}[\]()#+\-.!|<>])/g, '\\$1');
|
|
14
|
+
}
|
|
15
|
+
export function maxBackticks(text) {
|
|
16
|
+
let max = 0;
|
|
17
|
+
let current = 0;
|
|
18
|
+
for (let i = 0; i < text.length; i++) {
|
|
19
|
+
if (text[i] === '`') {
|
|
20
|
+
current++;
|
|
21
|
+
max = Math.max(max, current);
|
|
22
|
+
} else {
|
|
23
|
+
current = 0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return max;
|
|
27
|
+
}
|
|
12
28
|
//# sourceMappingURL=utils.mjs.map
|
package/dist/esm/utils.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":["joinBlocks","blocks","map","trimBlock","filter","Boolean","join","block","replace","prefixLines","text","prefix","lines","split","line"],"sources":["../../src/utils.ts"],"sourcesContent":["/**\n * Join blocks of text into a single markdown document (string).\n *\n * @param blocks - The blocks of text to join.\n * @returns Markdown document string.\n */\nexport function joinBlocks(blocks: string | readonly string[]): string {\n blocks = typeof blocks === 'string' ? [blocks] : blocks;\n\n return blocks.map(trimBlock).filter(Boolean).join('\\n\\n');\n}\n\nfunction trimBlock(block: string): string {\n return block.replace(/^\\n+|\\n+$/g, '');\n}\n\nexport function prefixLines(text: string, prefix: string): string {\n const lines = text.split('\\n');\n return lines.map((line) => `${prefix}${line}`).join('\\n');\n}\n"],"mappings":"AAMA,OAAO,SAASA,UAAUA,CAACC,MAAkC,EAAU;EACrEA,MAAM,GAAG,OAAOA,MAAM,KAAK,QAAQ,GAAG,CAACA,MAAM,CAAC,GAAGA,MAAM;EAEvD,OAAOA,MAAM,CAACC,GAAG,CAACC,SAAS,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,MAAM,CAAC;AAC3D;AAEA,SAASH,SAASA,CAACI,KAAa,EAAU;EACxC,OAAOA,KAAK,CAACC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;AACxC;AAEA,OAAO,SAASC,WAAWA,CAACC,IAAY,EAAEC,MAAc,EAAU;EAChE,MAAMC,KAAK,GAAGF,IAAI,CAACG,KAAK,CAAC,IAAI,CAAC;EAC9B,OAAOD,KAAK,CAACV,GAAG,CAAEY,IAAI,IAAK,GAAGH,MAAM,GAAGG,IAAI,EAAE,CAAC,CAACR,IAAI,CAAC,IAAI,CAAC;AAC3D","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":["joinBlocks","blocks","map","trimBlock","filter","Boolean","join","block","replace","prefixLines","text","prefix","lines","split","line","escape","maxBackticks","max","current","i","length","Math"],"sources":["../../src/utils.ts"],"sourcesContent":["/**\n * Join blocks of text into a single markdown document (string).\n *\n * @param blocks - The blocks of text to join.\n * @returns Markdown document string.\n */\nexport function joinBlocks(blocks: string | readonly string[]): string {\n blocks = typeof blocks === 'string' ? [blocks] : blocks;\n\n return blocks.map(trimBlock).filter(Boolean).join('\\n\\n');\n}\n\nfunction trimBlock(block: string): string {\n return block.replace(/^\\n+|\\n+$/g, '');\n}\n\nexport function prefixLines(text: string, prefix: string): string {\n const lines = text.split('\\n');\n return lines.map((line) => `${prefix}${line}`).join('\\n');\n}\n\nexport function escape(text: string): string {\n return text.replace(/([\\\\`*_{}[\\]()#+\\-.!|<>])/g, '\\\\$1');\n}\n\nexport function maxBackticks(text: string): number {\n let max = 0;\n let current = 0;\n\n for (let i = 0; i < text.length; i++) {\n if (text[i] === '`') {\n current++;\n max = Math.max(max, current);\n } else {\n current = 0;\n }\n }\n\n return max;\n}\n"],"mappings":"AAMA,OAAO,SAASA,UAAUA,CAACC,MAAkC,EAAU;EACrEA,MAAM,GAAG,OAAOA,MAAM,KAAK,QAAQ,GAAG,CAACA,MAAM,CAAC,GAAGA,MAAM;EAEvD,OAAOA,MAAM,CAACC,GAAG,CAACC,SAAS,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,MAAM,CAAC;AAC3D;AAEA,SAASH,SAASA,CAACI,KAAa,EAAU;EACxC,OAAOA,KAAK,CAACC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;AACxC;AAEA,OAAO,SAASC,WAAWA,CAACC,IAAY,EAAEC,MAAc,EAAU;EAChE,MAAMC,KAAK,GAAGF,IAAI,CAACG,KAAK,CAAC,IAAI,CAAC;EAC9B,OAAOD,KAAK,CAACV,GAAG,CAAEY,IAAI,IAAK,GAAGH,MAAM,GAAGG,IAAI,EAAE,CAAC,CAACR,IAAI,CAAC,IAAI,CAAC;AAC3D;AAEA,OAAO,SAASS,MAAMA,CAACL,IAAY,EAAU;EAC3C,OAAOA,IAAI,CAACF,OAAO,CAAC,4BAA4B,EAAE,MAAM,CAAC;AAC3D;AAEA,OAAO,SAASQ,YAAYA,CAACN,IAAY,EAAU;EACjD,IAAIO,GAAG,GAAG,CAAC;EACX,IAAIC,OAAO,GAAG,CAAC;EAEf,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGT,IAAI,CAACU,MAAM,EAAED,CAAC,EAAE,EAAE;IACpC,IAAIT,IAAI,CAACS,CAAC,CAAC,KAAK,GAAG,EAAE;MACnBD,OAAO,EAAE;MACTD,GAAG,GAAGI,IAAI,CAACJ,GAAG,CAACA,GAAG,EAAEC,OAAO,CAAC;IAC9B,CAAC,MAAM;MACLA,OAAO,GAAG,CAAC;IACb;EACF;EAEA,OAAOD,GAAG;AACZ","ignoreList":[]}
|
package/dist/types/block.d.ts
CHANGED
|
@@ -27,19 +27,21 @@ export declare function heading(text: string, options?: HeadingOptions): string;
|
|
|
27
27
|
* @param text - The content of the blockquote.
|
|
28
28
|
*/
|
|
29
29
|
export declare function blockquote(content: string | readonly string[]): string;
|
|
30
|
+
type CodeBlockOptions = {
|
|
31
|
+
language?: string;
|
|
32
|
+
};
|
|
30
33
|
/**
|
|
31
34
|
* Create a code block.
|
|
32
35
|
*
|
|
33
36
|
* Markdown:
|
|
34
|
-
*
|
|
35
|
-
* ```
|
|
37
|
+
* ```js
|
|
36
38
|
* Content
|
|
37
39
|
* ```
|
|
38
|
-
* ````
|
|
39
40
|
*
|
|
40
41
|
* @param content - The content of the code block.
|
|
42
|
+
* @param language - The language of the code block.
|
|
41
43
|
*/
|
|
42
|
-
export declare function codeBlock(content: string): string;
|
|
44
|
+
export declare function codeBlock(content: string, options?: CodeBlockOptions): string;
|
|
43
45
|
/**
|
|
44
46
|
* Create an unordered list block.
|
|
45
47
|
*
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export { horizontalRule, heading, blockquote, orderedList, list, codeBlock } fro
|
|
|
2
2
|
export { code, italic, bold, link, image } from './inline';
|
|
3
3
|
export { table } from './table';
|
|
4
4
|
export { lineBreak, disclosure } from './html';
|
|
5
|
-
export { joinBlocks } from './utils';
|
|
5
|
+
export { escape, joinBlocks } from './utils';
|
|
6
6
|
export type { TableOptions } from './table';
|
|
7
7
|
export type { DisclosureOptions } from './html';
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -6,3 +6,5 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function joinBlocks(blocks: string | readonly string[]): string;
|
|
8
8
|
export declare function prefixLines(text: string, prefix: string): string;
|
|
9
|
+
export declare function escape(text: string): string;
|
|
10
|
+
export declare function maxBackticks(text: string): number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-markdown-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Elegant markdown builder with minimal bundle size.",
|
|
5
5
|
"main": "dist/commonjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.mjs",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"build:esm": "BABEL_ENV=esm babel src --out-dir \"dist/esm\" --extensions .js,.ts --out-file-extension .mjs --source-maps --no-comments",
|
|
30
30
|
"build:types": "tsc --project tsconfig.release.json --outDir \"dist/types\"",
|
|
31
31
|
"release": "release-it",
|
|
32
|
-
"release:beta": "release-it --preRelease=beta"
|
|
32
|
+
"release:beta": "release-it --preRelease=beta",
|
|
33
|
+
"validate": "yarn typecheck && yarn lint && yarn test"
|
|
33
34
|
},
|
|
34
35
|
"keywords": [
|
|
35
36
|
"markdown",
|
|
@@ -46,29 +47,29 @@
|
|
|
46
47
|
"registry": "https://registry.npmjs.org/"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@babel/cli": "^7.
|
|
50
|
-
"@babel/core": "^7.
|
|
51
|
-
"@babel/plugin-syntax-flow": "^7.
|
|
52
|
-
"@babel/plugin-transform-react-jsx": "^7.
|
|
53
|
-
"@babel/preset-env": "^7.
|
|
54
|
-
"@babel/preset-typescript": "^7.
|
|
50
|
+
"@babel/cli": "^7.28.3",
|
|
51
|
+
"@babel/core": "^7.28.3",
|
|
52
|
+
"@babel/plugin-syntax-flow": "^7.27.1",
|
|
53
|
+
"@babel/plugin-transform-react-jsx": "^7.27.1",
|
|
54
|
+
"@babel/preset-env": "^7.28.3",
|
|
55
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
55
56
|
"@callstack/eslint-config": "^15.0.0",
|
|
56
|
-
"@release-it/conventional-changelog": "^
|
|
57
|
-
"@size-limit/preset-small-lib": "^11.
|
|
58
|
-
"@types/jest": "^
|
|
57
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
58
|
+
"@size-limit/preset-small-lib": "^11.2.0",
|
|
59
|
+
"@types/jest": "^30.0.0",
|
|
59
60
|
"babel-plugin-add-import-extension": "^1.6.0",
|
|
60
61
|
"del-cli": "^6.0.0",
|
|
61
|
-
"eslint": "^8.57.
|
|
62
|
-
"eslint-config-prettier": "^
|
|
62
|
+
"eslint": "^8.57.1",
|
|
63
|
+
"eslint-config-prettier": "^10.1.8",
|
|
63
64
|
"eslint-plugin-flowtype": "^8.0.3",
|
|
64
|
-
"eslint-plugin-import": "^2.
|
|
65
|
-
"eslint-plugin-prettier": "^
|
|
66
|
-
"jest": "^
|
|
67
|
-
"prettier": "^
|
|
68
|
-
"release-it": "^
|
|
69
|
-
"typescript": "^5.
|
|
65
|
+
"eslint-plugin-import": "^2.32.0",
|
|
66
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
67
|
+
"jest": "^30.1.2",
|
|
68
|
+
"prettier": "^3.6.2",
|
|
69
|
+
"release-it": "^19.0.4",
|
|
70
|
+
"typescript": "^5.9.2"
|
|
70
71
|
},
|
|
71
|
-
"packageManager": "yarn@4.4.
|
|
72
|
+
"packageManager": "yarn@4.9.4+sha512.7b1cb0b62abba6a537b3a2ce00811a843bea02bcf53138581a6ae5b1bf563f734872bd47de49ce32a9ca9dcaff995aa789577ffb16811da7c603dcf69e73750b",
|
|
72
73
|
"engines": {
|
|
73
74
|
"node": ">= 18.0.0"
|
|
74
75
|
},
|